﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BusinessLayer.FindArtInfo.Entities;
using DBHelper;
using System.Data.SqlClient;
using System.Data;
using BusinessLayer.FindArtInfo.Models;

namespace BusinessLayer.FindArtInfo
{
    public class CountryBL
    {        
        public List<Country> GetAll()
        {
            List<Country> result = new List<Country>();
            var adapter = new BaseDAO(DbConfig.DbFindArtInfoConnectionString);
            try
            {
                result = adapter.GetList<Country>("sp_Country_Select_All", CommandType.StoredProcedure, CustomConnectionState.CloseOnExit);
            }
            catch (Exception)
            {
            }
            finally { adapter.Dispose(); }
            return result;
        }

        public Country GetById(int id)
        {
            Country result = new Country();
            var adapter = new BaseDAO(DbConfig.DbFindArtInfoConnectionString);
            adapter.AddParameter("@Id", id);
            try
            {
                result = adapter.GetList<Country>("sp_Country_GetById", CommandType.StoredProcedure, CustomConnectionState.CloseOnExit).FirstOrDefault();
            }
            catch (Exception)
            {
            }
            finally { adapter.Dispose(); }
            return result;
        }
    }
}
